package wservice;

import java.io.Serializable;
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;

public class RequestParam implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 35438572354815133L;

	/**
	 * 应用
	 */
	private String app ;
	
	/**
	 * 模块
	 */
	private String module ;
	
	/**
	 * 动作
	 */
	private String action ; 
	
	/**
	 * 用户Key
	 */
	private String accessKey ; //
	
	/**
	 * 时间戳
	 */
	private String timestamp; //
	
	/**
	 * 请求参数
	 */
	private Map<String, String> paramMap ; //
	
	/**
	 * 指纹
	 */
	private String hmac ;
	
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((accessKey == null) ? 0 : accessKey.hashCode());
		result = prime * result + ((action == null) ? 0 : action.hashCode());
		result = prime * result + ((app == null) ? 0 : app.hashCode());
		result = prime * result + ((hmac == null) ? 0 : hmac.hashCode());
		result = prime * result + ((module == null) ? 0 : module.hashCode());
		result = prime * result
				+ ((paramMap == null) ? 0 : paramMap.hashCode());
		result = prime * result
				+ ((timestamp == null) ? 0 : timestamp.hashCode());
		return result;
	}



	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		RequestParam other = (RequestParam) obj;
		if (accessKey == null) {
			if (other.accessKey != null)
				return false;
		} else if (!accessKey.equals(other.accessKey))
			return false;
		if (action == null) {
			if (other.action != null)
				return false;
		} else if (!action.equals(other.action))
			return false;
		if (app == null) {
			if (other.app != null)
				return false;
		} else if (!app.equals(other.app))
			return false;
		if (hmac == null) {
			if (other.hmac != null)
				return false;
		} else if (!hmac.equals(other.hmac))
			return false;
		if (module == null) {
			if (other.module != null)
				return false;
		} else if (!module.equals(other.module))
			return false;
		if (paramMap == null) {
			if (other.paramMap != null)
				return false;
		} else if (!paramMap.equals(other.paramMap))
			return false;
		if (timestamp == null) {
			if (other.timestamp != null)
				return false;
		} else if (!timestamp.equals(other.timestamp))
			return false;
		return true;
	}



	/**
	 * 
	 * @return
	 */
	public SortedMap<String, String> getSerializableMap() {
		SortedMap<String, String> map = new TreeMap<String, String>();
		map.put("accessKey", accessKey);
		map.put("timestamp", timestamp);
		map.putAll(paramMap);
		return map ;
	}
	


	public String getAccessKey() {
		return accessKey;
	}

	public String getAction() {
		return action;
	}

	public String getApp() {
		return app;
	}

	public String getHmac() {
		return hmac;
	}

	public String getModule() {
		return module;
	}

	public Map<String, String> getParamMap() {
		return paramMap;
	}

	
	public String getTimestamp() {
		return timestamp;
	}

	public void setAccessKey(String accessKey) {
		this.accessKey = accessKey;
	}

	public void setAction(String action) {
		this.action = action;
	}

	public void setApp(String app) {
		this.app = app;
	}

	public void setHmac(String hmac) {
		this.hmac = hmac;
	}

	public void setModule(String module) {
		this.module = module;
	}

	public void setParamMap(Map<String, String> paramMap) {
		this.paramMap = paramMap;
	}

	public void setTimestamp(String timestamp) {
		this.timestamp = timestamp;
	}

	
}
